import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xin_he/routes/xin_he_routes.dart';
import 'package:xin_he/utils/xin_he_input_widget.dart';

import '../../../utils/xh_styles.dart';
import '../../../utils/xin_he_image.dart';
import 'xin_he_mine_withdraw_logic.dart';

class XinHeMineWithdrawPage extends StatelessWidget {
  XinHeMineWithdrawPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHeMineWithdrawLogic());
  final state = Get.find<XinHeMineWithdrawLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
      appBar: AppBar(
        leading: IconButton(
            onPressed: (){
              Get.back();
            },
            icon: Container(
              padding: const EdgeInsets.only(left: 7),
              alignment: Alignment.centerLeft,
              child: const XinHeAssetImage(
                'assets/images/home/app_back_3.png',
                width: 9.5,
                height: 17,
                fit: BoxFit.cover,),
            )
        ),
        backgroundColor: Colors.white,
        shadowColor: Colors.transparent,
        title: Text('提现',style: TextStyle(color:XinHeColor('#222222'),fontSize: 17,fontWeight: FontWeight.w600)),
        centerTitle: true,
      ),
      body: Column(children: [
        Container(
          height: 40,
          padding: const EdgeInsets.symmetric(horizontal: 15),
          alignment: Alignment.centerLeft,
          child: Text('余额提现到银行卡',style: TextStyle(color: XinHeColor('#666666'),fontSize: 13,fontWeight: FontWeight.w500 ),),
        ),

        Container(
          margin: const EdgeInsets.symmetric(horizontal: 15),
          padding: const EdgeInsets.symmetric(horizontal: 15),
          decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(10)),
          child: Column(children: [
            const SizedBox(height: 12,),

            Row(children: [
              Container(
                  height: 23,
                  alignment: Alignment.centerLeft,
                  child: Text('提现类型',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500 ),)),
              Spacer(),
              Container(
                  padding: const EdgeInsets.symmetric(vertical: 8).copyWith(left: 8,right: 8),
                  color: Colors.transparent,
                  child: XinHeAssetImage( 'assets/images/cart/cart_selected.png',width:15 ,height: 15,)),
              Text('银行卡')
            ],),

            SizedBox(height: 30,),



            logic.bankModel.value.id != null
                ?  GestureDetector(
              behavior: HitTestBehavior.opaque,
              onTap: (){
                      Get.toNamed(XinHeRoutes.bankManagement);
                  },
                  child: Row(children: [
              Container(
                    height: 23,
                    alignment: Alignment.centerLeft,
                    child: Text('添加银行卡',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500 ),)),
              Spacer(),
              const XinHeAssetImage('assets/images/cart/pay_arrow.png',width: 6,height: 10,),
            ],),
                ) :  GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: (){
                    Get.toNamed(XinHeRoutes.bankManagement);
                  },
                  child: Row(children: [
              Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                  Container(
                      height: 23,
                      alignment: Alignment.centerLeft,
                      child: Text(logic.bankModel.value.bankName??'',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500 ),)),
                  Text(logic.bankModel.value.code??'',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500 ),),

              ],),
              Spacer(),
              const XinHeAssetImage('assets/images/cart/pay_arrow.png',width: 6,height: 10,),
            ],),
                ),


            const SizedBox(height: 12,),


          ],),
        ),

        const SizedBox(height:39 ,),


        Container(
          margin: const EdgeInsets.symmetric(horizontal: 15),
          padding: const EdgeInsets.symmetric(horizontal: 15),
          decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(10)),
          child: Column(children: [
            const SizedBox(height: 12,),

            Container(
                height: 23,
                alignment: Alignment.centerLeft,
                child: Text('提现金额',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500 ),)),
            Container(
              height: 35,
              width: Get.width-30,
              alignment: Alignment.centerLeft,
              child: Row(
                children: [
                  Text('¥',style: TextStyle(color: XinHeColor('#333333'),fontSize: 15,fontWeight: FontWeight.w500 ),),

                  Expanded(
                    child: Container(
                      height:35,
                      margin: const EdgeInsets.only(left: 10),
                      child: XinHeInputWidget('', '请输入提现金额，100的整数倍', (value){

                      },keyboardType: TextInputType.number,fontSize: 15,hintFontSize: 11,containerH: 35,isHiddenLine: true,),
                    ),
                  ),
                  Container(
                      width: 60,
                      alignment: Alignment.center,
                      child: Text('全部提现',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500 ),)),
                ],),
            ),
            Container(width: Get.width-30,height: 0.5,color: XinHeStyle.lineColor,),
            Container(
                height: 29,
                margin: const EdgeInsets.only(bottom: 23),
                alignment: Alignment.centerLeft,
                child: Text('提现后账户余额不能低于5元.',style: TextStyle(color: XinHeColor('#919191'),fontSize: 11,fontWeight: FontWeight.w500 ),)),





          ],),
        ),


        const SizedBox(height:39 ,),
        GestureDetector(
          onTap: (){
            logic.withdraw();
          },
          child: Container(
            margin:  const EdgeInsets.only(left: 15,right: 14,top: 0),
            height: 45,
            width: double.infinity,
            alignment: Alignment.center,
            decoration: BoxDecoration(color:  XinHeColor('#10C9C9'),borderRadius: BorderRadius.all(Radius.circular(22.5))),
            child: const Text (
              "确认提现",
              style: TextStyle (fontSize: 16,color:  Colors.white,fontWeight: FontWeight.w600) ,
            ),),
        ),
        SizedBox(height: 5,),
        Text('温馨提示：提交申请后，预计T+1个工作日到账。 ',style: TextStyle(color: XinHeColor('#919191'),fontSize: 11,fontWeight: FontWeight.w500),)

      ],),

    ));
  }
}
